<!--- 文章详情页目录列表toc --->
<template>
 <div class="article-toc" v-if="article_toc">
    <h4>大纲</h4>
    <div class="side-line"></div>
    <div class="toc-content" v-html="article_toc || ''"></div>
</div>
</template>
<script setup>
defineProps({
  article_toc: {
    type: String,
    default: ''
  }
})
</script>
<style scoped>
.article-toc {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 10px;
    margin-bottom: 20px;
    background-color: var(--card-bg-color,#fff);
    border-radius: 4px;
}
.side-line {
    height: 1px;
    background-color: var(--article-detail-text-color,#ccc);
    margin-top: 10px;
    margin-bottom: 10px;
}
.toc-container {
  position: sticky;
  max-width: 280px;
  padding: 20px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.toc-title {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 15px;
  position: relative;
  padding-left: 12px;
}

.toc-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 16px;
  background: linear-gradient(to bottom, #007bff, #3da5ff);
  border-radius: 2px;
}

.toc-content {
  font-size: 14px;
  line-height: 1.6;
}

.toc-content :deep(ul) {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.toc-content :deep(li) {
  margin: 6px 0;
  padding-left: 1em;
  position: relative;
}

.toc-content :deep(a) {
  color: #4a5568;
  text-decoration: none;
  transition: color 0.2s;
}

.toc-content :deep(a:hover) {
  color: #007bff;
}

/* 不同层级样式 */
.toc-content :deep(.toc-h2) {
  font-weight: 500;
  margin-left: 0;
}

.toc-content :deep(.toc-h3) {
  margin-left: 1em;
  font-weight: 400;
}

.toc-content :deep(.toc-h4) {
  margin-left: 2em;
  font-size: 13px;
  color: #718096;
}

.toc-content :deep(.active) {
  color: #007bff !important;
  font-weight: 500;
}
</style>